/**
 * Created on 2018/8/11.
 */
package jetcache.samples.springboot;

import com.alicp.jetcache.anno.config.EnableMethodCache;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.UUID;
import java.util.concurrent.TimeUnit;

/**
 * @author huangli
 */
@SpringBootApplication
@EnableMethodCache(basePackages = "jetcache")
public class RedissonDemo2 {

    public static void main(String[] args) throws InterruptedException {
        ConfigurableApplicationContext context = SpringApplication.run(RedissonDemo2.class);
        MyService myService = context.getBean(MyService.class);
        new Thread(()-> {
            while (true) {
                try {
                    TimeUnit.SECONDS.sleep(5);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                User user = new User();
                user.setUserId(1L);
                user.setUserName(UUID.randomUUID().toString());
                myService.updateUser(user);
            }
        }).start();
    }
}
